//
//  CZOrderCell.m
//  TCProject
//
//  Created by admin on 16/1/28.
//  Copyright © 2016年 wise-wing. All rights reserved.
//

#import "CZOrderCell.h"
@interface CZOrderCell()
@property (weak, nonatomic) IBOutlet UIButton *orderNoButton;

@property (weak, nonatomic) IBOutlet UILabel *priceLabel;

@property (weak, nonatomic) IBOutlet UILabel *statusLabel;

@property (weak, nonatomic) IBOutlet UIButton *dateButton;
@property (weak, nonatomic) IBOutlet UIButton *transNumButton;
@property (weak, nonatomic) IBOutlet UIButton *carStyleButton;
@property (weak, nonatomic) IBOutlet UIButton *singlePriceButton;
@property (weak, nonatomic) IBOutlet UIButton *distanceButton;
- (IBAction)callAction:(id)sender;

@end

@implementation CZOrderCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setOrder:(CZOrder *)order{
    _order = order;
    
    [self.orderNoButton setTitle:[NSString stringWithFormat:@"用车时间：%@", _order.appointmentTime] forState:UIControlStateNormal];
    if (_order.statusId == ZDOwnerStatusEnded || _order.statusId == ZDOwnerStatusCommented) {
        self.priceLabel.text = [NSString stringWithFormat:@"￥%.1f", _order.totalRealSumPrice];
    } else {
        self.priceLabel.text = [NSString stringWithFormat:@"￥%.1f", _order.sumPrice];
    }
    [self.dateButton setTitle:[NSString stringWithFormat:@"站点名称：%@", _order.stationName] forState:UIControlStateNormal];
    [self.transNumButton setTitle:[NSString stringWithFormat:@"需求方量：%.1f方", _order.volume] forState:UIControlStateNormal];
    [self.carStyleButton setTitle:[NSString stringWithFormat:@"需求车型：%@(%ld辆)", _order.style1, _order.count] forState:UIControlStateNormal];
    [self.distanceButton setTitle:[NSString stringWithFormat:@"%@：%@", _order.conditionName, _order.condition] forState:UIControlStateNormal];
    
    self.statusLabel.textColor = [OrderLog getStatusColor:_order.statusId];
    self.statusLabel.text = [OrderLog getStatusMsg:_order.statusId];
    
    double singlePrice = _order.sumPrice / _order.volume;
    [self.singlePriceButton setTitle:[NSString stringWithFormat:@"方量单价：%.1f元/方", singlePrice] forState:UIControlStateNormal];
}

- (IBAction)callAction:(id)sender {
     [BMUtils callWithPhoneNumber:_order.disPhone];
}
@end
